<template>
  <view :class="['king-kong', { small: kingKongList.length > 3 }]">
    <view
      class="king-kong-item"
      v-for="(item, index) in kingKongList"
      :key="index"
      @click="handleKingKong(item)"
    >
      <image :src="item.img"></image>
      <text>{{ item.label }}</text>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      kingKongList: this.$indexKingKong(this.$imgBaseSelf),
    };
  },
  methods: {
    handleKingKong(item) {
      let url = item.url;
      if (item.isWeb) {
        url = `/pagesSub/public/web/index?title=${item.label}&link=${encodeURIComponent(item.url)}`;
      }
      uni.navigateTo({ url });
    },
  },
};
</script>

<style lang="scss">
.king-kong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 44rpx 32rpx;
  border-radius: 54rpx;
  .king-kong-item {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 22rpx 0;
    width: 213rpx;
    background-color: rgba($color: #ffffff, $alpha: 0.8);
    border-radius: 50rpx;
    font-size: 24rpx;
    image {
      display: block;
      width: 91rpx;
      height: 91rpx;
      border-radius: 34rpx;
    }
    text {
      width: 90rpx;
      display: block;
      font-size: $uni-font-size-nor;
      font-weight: bold;
      color: $uni-text-color-222;
      margin-left: 8rpx;
      margin-right: -10rpx;
    }
  }
  &.small {
    .king-kong-item {
      flex-grow: 0;
      flex-shrink: 1;
      flex-direction: column;
      margin-left: 24rpx;
      padding: 18rpx 0;
      image {
        margin-bottom: 8rpx;
        width: 64rpx;
        height: 64rpx;
      }
      text {
        margin: 0;
        text-align: center;
        font-size: $uni-font-size-sm;
      }
      &:first-of-type {
        margin-left: 0;
      }
    }
  }
}
</style>